package com.zyf.audio.util;

import com.alibaba.fastjson.JSONObject;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

/**
 * Created by hp on 2021/10/18.
 */
public class SqlUtil {
    public static JSONObject query(String param){
        JSONObject job = new JSONObject();
        Connection conn = null;
        try{
            conn = DruidUtil.getConn();
            String sql = "SELECT * FROM  device_view_new where url = ?";
            PreparedStatement ps = conn.prepareStatement(sql);
            ps.setString(1,param);

            ResultSet rs = ps.executeQuery();
            while (rs.next()){
                job.put("url",rs.getString("url"));
                job.put("id",rs.getString("id"));
                job.put("db",rs.getInt("db"));
                job.put("state",rs.getInt("state"));
                job.put("kw",rs.getString("kk"));
                break;
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            try {
                if (conn!=null) conn.close();
            }catch (Exception e){
                e.printStackTrace();
            }
        return job;
        }
    }
}
